//
//  BaseLab.m
//  ZITHER
//
//  Created by weixin on 2018/10/11.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "BaseLab.h"

@implementation BaseLab

-(instancetype)initializeFrame:(CGRect)frame text:(NSString*)text font:(NSInteger)font textColor:(UIColor *)textColor isBold:(BOOL)isBold numberOfLines:(NSInteger)numberOfLines{
    [self init].frame = frame;
    

    
    self.text = text;
    
    if (font!=0) {
        if (isBold) {
            self.font = [UIFont fontWithName:@"Helvetica-Bold" size:font];
        }else{
            self.font = [UIFont systemFontOfSize:font];
        }
    }
    
    self.numberOfLines = numberOfLines;
    if (textColor) self.textColor = textColor;
    
    return self;
}

/** 设置行间距 */
-(void)setLineSpacingText:(NSString*)text lineSpacing:(CGFloat)lineSpacing{
    
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle.lineSpacing = lineSpacing;
        paragraphStyle.lineBreakMode = self.lineBreakMode;
        paragraphStyle.alignment = self.textAlignment;
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
        self.attributedText = attributedString;

}

-(RACSignal *)addTag{
    /** 添加点击事件 */
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
    self.userInteractionEnabled = YES;
    [self addGestureRecognizer:tap];
    return [tap rac_gestureSignal];
    
}

+(instancetype)initCustomLab:(NSString*)Title color:(UIColor*)colors font:(UIFont*)font{

    BaseLab *lab = [[BaseLab alloc]init];
    lab.backgroundColor = [UIColor randomColor];
    
    lab.text = Title;
    lab.font = font;
    lab.textColor = colors;

    
    return lab;
}

@end
